#include<bits/stdc++.h>
#define int long long
using namespace std;

const int N = 1.5 * 1e6 + 10;
vector<int>v[N];
int a[N], fl;
int n, K;
void dfs(int x, int fa, int dep, int cnt) {
	if(dep == K) {
		if(cnt != 1) fl = 1;
		return;
	}
	for(int i = 0; i < v[x].size(); i++) {
		int y = v[x][i];
		if(y == fa) continue;
		dfs(y, x, dep + 1, cnt + a[y]);
	}
}
signed main() {
	freopen("life.in", "r", stdin);
	freopen("life.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n >> K;
	for(int i = 1; i < n; i++) {
		int x, y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	if(n <= 18) {
		int ans = 0;
		for(int i = 0; i < (1 << n); i++) {
			for(int j = 1; j <= n; j++) a[j] = 0;
			for(int j = 1; j <= n; j++) {
				if(i & (1 << (j - 1))) {
					a[j] = 1;
				}
			}
			fl = 0;
			for(int j = 1; j <= n; j++) dfs(j, 0, 1, a[j]);
			if(!fl) ++ans;
		}
		if(ans) {
			cout << "YES\n";
			cout << ans;
		}
		else cout << "NO\n0";
		return 0;
	}
	cout << "YES\n";
	cout << K;
}
